<style>.input-border>input{border:1px solid #32c787;border-radius:5px;text-align:center;}li{
list-style:none;
margin-top:20px;
}</style>
<div class="modal fade" id="breakfast-add" data-keyboard="false" data-backdrop="static" tabindex="-1">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h3 class="modal-title pull-left" id="breakfast-modal-title">早餐券</h3>
            </div>
            <div class="modal-body">
                <form id="breakfast-add-form">
                <!--form 表单  -->
                
					<div id='dialog' style='margin:0 auto;width:400px;height:280px;background:#fff;'>
					
					<ul style='margin-left:45px;display:inline-block;vertical-align:top;height:199px;'>
						<li>早餐日期</li>
						<li style='margin-top:22px;'>每日数量</li>
						<li style='margin-top:27px;'>手机号</li>
						<li style='margin-top:27px;'>房间号</li>
						<li style='margin-top:30px;'>总数量</li>
					</ul>
					<ul style='display:inline-block;width:50%;vertical-align:top;'>
						<li>
							<input readonly="" type="text" class="demo-input" placeholder="请选择日期" id="test6">
						</li>
						<li>
							<input onclick='reduce()' type="button" style='width:30px;' value="-">
							<span id="number" style='margin-left:10px;' name="numDaily">2</span>
							<input onclick='add()' style='width:30px;margin-left:10px;' type="button" value="+">
						</li>
						<li>
							<input id='shoujiP' style='width:100%;' name="mobile" type="text" onblur="phone()" placeholder="请输入手机号">
						</li>
						<li>
							<input style='width:100%;' type="text" id="roomNo"  name="roomNo">
						</li>
						<li>
							<span id="amount" name="amount">2</span>张
						</li>
					</ul>
					<div style="clear:both;"></div>
					<!-- <p style='text-align:center;'>
						<button onclick='cancle()' style='width:80px;'>取消</button>
						<a onclick='design()' style='width:80px;margin-left:60px;'>确定</a>
					</p> -->
			</div> 
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-save" id="coupon-add-button" name="save">保存</button>
                <button type="button" class="btn btn-secondary btn-close">关闭</button>
                <button class="btn-hide"></button>
            </div>
        </div>
    </div>
</div>

<!-- <script data-th-src="@{js/laydate/laydate.js}"></script> -->
<script>

lay('#version').html('-v'+ laydate.v);
function addday(days){
	var date = new Date();
	var dt=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
	dt = dt.replace(/'-'/g, '/');//js不认2011-11-10,只认2011/11/10
	var t1 = new Date(new Date(dt).valueOf() + days*24*60*60*1000);// 日期加上指定的天数
	var month;
	var day;
	if((t1.getMonth() + 1)<10)
	{
	month="0"+(t1.getMonth() + 1);
	}
	else
	{
	month=t1.getMonth() + 1;
	}
	if(t1.getDate()<10)
	{
	day="0"+t1.getDate();
	}
	else
	{
	day=t1.getDate();
	}
	var ttt= t1.getFullYear() + "-" + month + "-" + day;
	nextDate=ttt
}

function setTime(){
	
	$("#test6").removeAttr("lay-key")
	var date = new Date(); //日期对象
    now = "";
//当前日期添加一天
var nowDay=new Date();
now1= date.getFullYear()+"-"; //读英文就行了
now2= now + (date.getMonth()+1)+"-"; //取月的时候取的是当前月-1如果想取当前月+1就可以了
now3= now + date.getDate();
 nowDate=now1+now2+now3;
/* 如果当前超过11点，设定如日期下一天； */
 
var nowHour = now + date.getHours();
function AddDay(dayIn) {
		var date=new Date();
		var myDate=new Date(date.getTime()+dayIn*24*60*60*1000);
		var year=myDate.getFullYear();
		var month=myDate.getMonth()+1;
		var day=myDate.getDate();
		CurrentDate=year+"-";
		if(month>=10)
		{
			CurrentDate=CurrentDate+month+"-";
		}
		else
		{
			CurrentDate=CurrentDate+"0"+month+"-";
		}
		if(day>=10)
		{
			CurrentDate=CurrentDate+day;
		}
		else
		{
			CurrentDate=CurrentDate+"0"+day;
		}
		
		return CurrentDate;
		
	}
/*  AddDay(dayIn) */
if(nowHour>11){
	 nowDate=AddDay(1)
	 addday(28);
}else{
	addday(27);
}
document.getElementById("test6").value=nowDate+" - "+ nowDate;

//日期范围
laydate.render({
  elem: '#test6',
 
  //trigger: 'click', //采用click弹出 
  range: true, 
  min:nowDate,
  max:nextDate,
    change: function(value, date){ //监听日期被切换
    	$("#test6").removeAttr("lay-key")
	    lay("#test6").val(value);
	    var numDaily=$.trim($("#number").html());
	  	var date=$("#test6").val();
		var start=new Date(date.substring(0,10));
		var end=new Date(date.substring(13,23));
		var date2=end.getTime()-start.getTime();  //时间差的毫秒数
		//计算出相差天数
		var days=Math.floor(date2/(24*3600*1000))+1;
		var sumNum=days*numDaily;
		$("#amount").html(sumNum); 
		
	},
	
});
}

function reduce(){
	var results=document.getElementById("number").innerHTML;
	var numDaily;
	if(results!=1){
		numDaily=Number(results)-1;
		document.getElementById("number").innerHTML=numDaily;
		var date=$("#test6").val();
		var start=new Date(date.substring(0,10));
		var end=new Date(date.substring(13,23));
		var date2=end.getTime()-start.getTime();  //时间差的毫秒数
		//计算出相差天数
		var days=Math.floor(date2/(24*3600*1000))+1;
		var sumNum=days*numDaily;
		$("#amount").html(sumNum);
	}
}
function add(){
	var results=document.getElementById("number").innerHTML;
	var numDaily;
	if(results<15){
		numDaily=Number(results)+1;
		document.getElementById("number").innerHTML=numDaily;
		var date=$("#test6").val();
		var start=new Date(date.substring(0,10));
		var end=new Date(date.substring(13,23));
		var date2=end.getTime()-start.getTime();  //时间差的毫秒数
		//计算出相差天数
		var days=Math.floor(date2/(24*3600*1000))+1;
		var sumNum=days*numDaily;
		$("#amount").html(sumNum);
	}
}
/* function addQ(){
	$("#dialog").show()
}
function cancle(){
	$("#dialog").toggle()
} */
function design(){
	 phone()
}
/* 
手机号校验 */
function phone(){
	/* 手机号正则校验 */
	 var phone = document.getElementById('shoujiP').value;
   if(!(/^1[34578]\d{9}$/.test(phone))){ 
    $MB.n_warning("手机格式不正确");
    document.getElementById('shoujiP').value="";
     return
   }/* else{
	   $("#dialog").toggle()
	  
   } */
}
</script>